package hanshunping.easy;

/**
 * @author ：蔡博
 * @description：TODO
 * @date ：2022/4/26 17:28
 */
public class OOPinterface {
    public static void main(String[] args) {
        Person t = new Person("唐僧",new VF().getH());
        t.work();

    }
}

interface Vehicles{
    void work();
}

class Horse implements Vehicles{
    public void work(){
        System.out.println("骑马");
    }
}

class Boat implements Vehicles{
    public void work(){
        System.out.println("开船");
    }
}

class VF{
    Horse getH(){
        Horse h = new Horse();
        return h;
    }

    Boat getB(){
        Boat b =new Boat();
        return b;
    }

}

class Person{
    String name;
    Vehicles v;
    public Person(String name,Vehicles v){
        this.name = name;
        this.v = v;
    }
    void work(){
        v.work();
    }
}